jQuery(function($) {
	$.get(ctx+"/web/sys/testapi/getallapis.json").success(function(json) {
		var html = $("#test-tpl").html();
		var tpl = Handlebars.compile(html);
		$("#test-tpl").after(tpl(json.d));
		$("button.am-btn-danger").click(function() {
            $tr = $(this).closest("tr");
            var apiurl= context+$tr.find("td:eq(0)").html().trim();
            if(apiurl.indexOf("/file/upload")>0){
            	var type=$("input[name='type']").val();
            	ajaxUploadfile(apiurl,{type:type},"fileinput",function(json){
            			$nexttr=$tr.next();
                		$nexttr.find("td").html(json)
                		$nexttr.show();
            	});
            }else{
                var param= $tr.find("td:eq(1) input").val();
                if(param){
                	apiurl=apiurl+"?"+param.trim();
                }
                $.get(apiurl).success(function(json) {
            		$nexttr=$tr.next();
            		$nexttr.find("td").html(JSON.stringify(json))
            		$nexttr.show();
                });
            }
        });
	});
});